package datastructure.ch08_bst.ch01_tree_base.node;

/**
 *
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
public class TreeNode<E> {
    public E element;
    public TreeNode<E> parent;
    public TreeNode<E> leftChild;
    public TreeNode<E> rightChild;

    public TreeNode() {
    }

    public TreeNode(E element, TreeNode<E> parent) {
        this.element = element;
        this.parent = parent;
    }

    public boolean isLeaf() {
        return leftChild == null && rightChild == null;
    }

    public boolean isTwoChildren() {
        return leftChild != null && rightChild != null;
    }
}
